{#
    Display a table of item names with current ACL rules; allow superusers to update ACL rules.
    ACL rule updates will fail downstream if superuser lacks admin permission.

    This template uses DIVs styled as TABLE parts so a FORM can span "table cells".
#}

{% extends theme("layout.html") %}

{% block content %}
    <h1>{{ _("Item ACLs") }}</h1>

    {% set button_text = _("Show/Hide items with default ACLs") %}
    <input onclick="$('.moin-acl-default').toggle()" value="{{ button_text }}" class="moin-button" type="button">
    <div class="moin-acl-count moin-acl-default">{{ _("Number items:") }} {{ number_items }}</div>
    <div style="display: table;" class="moin-acl-report">
        <div style="display: table-row;" class="moin-acl-heading">
            <div style="display: table-cell;">{{ _("Item Names") }}</div>
            <div style="display: table-cell;">{{ _("ACL") }}</div>
        </div>
        {% for item in items_acls %}
            {# we mark items using default ACLs with a special class so we can show/hide same with the click of a button #}
            {% if item['acl_default'] %}
                {% set default_style = "moin-acl-default" %}
            {% else %}
                {% set default_style = "" %}
            {% endif %}
            <form style="display: table-row;" class="{{ default_style }} moin-acl-form" action="{{ url_for('admin.modify_acl', item_name=item['fqname']) }}" method="POST">
                <div style="display: table-cell;" class="moin-acl-name-cell">
                    {{ utils.item_moniker(item, item.fqnames) }}
                    <input class="moin-button" type="submit" value="{{ _("Save") }}"/>
                </div>
                <div style="display: table-cell;" class="moin-acl-rule-cell">
                    <textarea class="moin-acl-string" name="{{ item['fqname'] }}">{{ item['acl'] }}</textarea>
                </div>
            </form>
        {% endfor %}
    </div>
{% endblock %}
